<!--_meta 作为公共模版分离出去-->
{{template "../public/header.html"}}
<!--/meta 作为公共模版分离出去-->

{{/*引入分页*/}}
<link rel="stylesheet" href="/static/page/page.css">
{{/*<script type="text/javascript" src="/static/page/jqPaginator.js"></script>*/}}

<link href="/static/admin/lib/lightbox2/2.8.1/css/lightbox.css" rel="stylesheet" type="text/css" >
<title>商品列表 - 商品列表</title>
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<div class="wap-container">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        首页
        <span class="c-gray en">/</span>
        商品管理
        <span class="c-gray en">/</span>
        商品列表
        <a class="btn btn-success radius f-r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>

    <form action="/{{config "String" "adminPath" ""}}/goods/index" method="get">

        <div class="panel">
            <div class="panel-body">
                <div class="row clearfix">

                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix mb-10">
                            <span class="col-xs-4 form-item-label">选择分类：</span>
                            <span class="col-xs-8 form-item-control">
                                <span class="select-box">
                                    <select id="classifyID" name="goods_cate_id" class="select">
                                        <option value="">&nbsp;&nbsp; 请选择 &nbsp;&nbsp;&nbsp; </option>
                                        {{range $key,$value := .goodsCate}}

                                            <option value="{{$value.Id}}">&nbsp;{{$value.Name}}</option>

                                            {{range $k,$v := $value.GoodsCateItem}}
                                                <option value="{{$v.Id}}">&nbsp;——&nbsp;{{$v.Name}}</option>
                                            {{end}}
                                        {{end}}
                                    </select>
                                </span>
                            </span>
                        </div>
                    </div>

                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix mb-10">
                            <span class="col-xs-4 form-item-label">开始日期：</span>
                            <span class="col-xs-8 form-item-control">
                                <input type="text" id="search-datetime-start" value="{{.startTimeDate}}" name="start_time" class="input-text datetimepicker-input">
                            </span>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix mb-10">
                            <span class="col-xs-4 form-item-label">结束日期：</span>
                            <span class="col-xs-8 form-item-control">
                                <input type="text" id="search-datetime-end" value="{{.endTimeDate}}" name="end_time" class="input-text datetimepicker-input">
                            </span>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix mb-10">
                            <span class="col-xs-4 form-item-label">关键字：</span>
                            <span class="col-xs-8 form-item-control">
                                <input type="text" name="keywords" value="{{.keywords}}" id="search-input" placeholder="关键字" class="input-text" />
                            </span>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix">
                            <span class="col-xs-4 form-item-control">
                                <button name="" id="search-submit" class="btn btn-success radius" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜资讯</button>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>

    <article class="Hui-admin-content clearfix">

        <div class="panel mt-20">
            <div class="panel-body">
                <div class="clearfix">
						<span class="f-l">
{{/*							<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>*/}}
{{/*							<a href="javascript:;" onclick="admin_add('添加商品','/{{config "String" "adminPath" ""}}/goods/add')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a>*/}}
						    <a class="btn btn-primary radius" onclick="product_add('添加商品','/{{config "String" "adminPath" ""}}/goods/add')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a>
                        </span>
                    <span class="f-r">共有数据：<strong>{{.lengthTotal}}</strong> 条</span>
                </div>
                <div class="mt-20 clearfix">
                    <table class="table table-border table-bordered table-bg table-hover table-sort">
                        <thead>
                        <tr>
                            <th scope="col" colspan="10">商品列表</th>
                        </tr>
                        <tr class="text-c">
                            {{/*                            <th width="25"><input type="checkbox" name="" value=""></th>*/}}
                            <th width="40">ID</th>
                            <th width="60">名称</th>
                            <th width="60">类别</th>
                            <th width="60">图片</th>
                            <th width="60">销售价</th>
                            <th width="60">成本价</th>
                            <th width="60">市场价</th>
                            <th width="60">库存</th>
                            <th width="90">加入时间</th>
                            <th width="100">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                            {{range $key,$value := .data}}
                            <tr class="text-c">
                                {{/*                            <td><input type="checkbox" value="1" name=""></td>*/}}
                                <td>{{$value.Id}}</td>
                                <td>{{$value.Name}}</td>
                                <td>{{$value.GoodsCate.Name}}</td>
                                <td>
                                    <a href="{{$value.Image}}" data-lightbox="gallery" data-title="{{$value.Name}}">
                                        <img style="width:35px;" src="{{$value.Image}}" alt="">
                                    </a>

                                </td>
                                <td>{{$value.Price}}</td>
                                <td>{{$value.Costprice}}</td>
                                <td>{{$value.Mktprice}}</td>
                                <td>{{$value.Stock}}</td>
                                <td>{{$value.Ctime | unixToDate}}</td>
                                <td class="td-manage">
                                    <a title="编辑" href="javascript:;" onclick="product_edit('商品编辑','/{{config "String" "adminPath" ""}}/goods/edit?id={{$value.Id}}','1')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
{{/*                                    <a class="btn btn-primary radius" onclick="product_add('添加商品','/{{config "String" "adminPath" ""}}/goods/add')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a>*/}}
                                    <a title="删除" href="javascript:;" onclick="admin_del(this,'{{$value.Id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                                </td>
                            </tr>
                            {{end}}
                        </tbody>
                    </table>
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                {{if eq .page 1}}{{else}}
                                <li>
                                    <a href="/{{config "String" "adminPath" ""}}/goods/index?page={{.prevPage}}" aria-label="Previous">上一页</a>
                                </li>
                                {{end}}
                                    {{range $key,$value := .paginate}}
                                        <li><a href="/{{config "String" "adminPath" ""}}/goods/index?page={{$value}}">{{$value}}</a></li>
                                    {{end}}
                                {{if ge .page .totalPage}}{{else}}
                                <li>
                                    <a href="/{{config "String" "adminPath" ""}}/goods/index?page={{.nextPage}}" aria-label="Next">下一页</a>
                                </li>
                                {{end}}

                                <li>
                                    <span>第{{.page}}页</span>
                                </li>
                            </ul>

                        </nav>

                </div>
            </div>
        </div>
    </article>
</div>

<!--_footer 作为公共模版分离出去-->
{{template "../public/footer.html"}}
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/admin/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/static/admin/static/business/js/main.js"></script>

<script type="text/javascript" src="/static/admin/lib/lightbox2/2.8.1/js/lightbox.min.js"></script>
<script type="text/javascript">
    $(function(){
        runDatetimePicker();
        // 全选 页面调用
        $(".table").HuicheckAll(
            {
                checkboxAll: 'thead input[type="checkbox"]',
                checkbox: 'tbody input[type="checkbox"]'
            },
            function(checkedInfo) {
                console.log(checkedInfo);
            }
        )
    });
    function admin_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'GET',
                url: '/{{config "String" "adminPath" ""}}/goods/delete?id='+id,
                dataType: 'json',
                success: function(data){
                    console.log(data);
                    if (data.code === 200){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg('删除失败!',{icon:2,time:1000});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

</script>
{{/*<script>
    $(function(){
        $('#pagination').jqPaginator({
            totalPages: {{.totalPages}},
            visiblePages: 10,
            currentPage: {{.page}},
            onPageChange: function (num, type) {
                console.log(num,type)
                if(type=="change"){
                    location.href="/{{config "String" "adminPath" ""}}/goods?page="+num;
                }
            }
        });
    })
</script>*/}}
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
